home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
misc
/
amag
/
AM9404_2.lha
/
tips & tricks
/
setprefs.asm
< prev
next >
Wrap
Assembly Source File
|
1994-02-28
|
3KB
|
160 lines
; --- Includes laden (Pfad individuell setzen)! ---
INCDIR maxon:include/
INCLUDE exec/memory.i
INCLUDE exec/exec_lib.i
INCLUDE dos/dos.i
INCLUDE dos/dos_lib.i
INCLUDE intuition/preferences.i
INCLUDE intuition/intuition_lib.i
; Individueller Startup-Code, muß jedoch in
; D1 Flag setzen, wegen Unterscheidung von
; CLI/WB ( D1=TRUE->WB ; D1=FALSE->CLI )
INCLUDE startup.asm
RSRESET
prefBuff rs.l 1
DosBase rs.l 1
IntBase rs.l 1
FileH rs.l 1
SIZE equ __RS
Begin
tst.l d1 ;kommen wir vom CLI?
bne Error_NULL ;nein -> Fehler
subq #1,d0
lea FileName(pc),a1
.loop1
cmp.b #" ",(a0) ;führende Spaces überlesen
bne.s .tstfil
lea 1(a0),a0
dbf d0,.loop1
.tstfil
move.b (a0),(a1)+ ;Filenamen
cmp.b #" ",(a0) ;holen
beq.s .getfil
cmp.b #$0a,(a0)+
beq.s .getfil
dbf d0,.tstfil
.getfil
clr.b -(a1) ;Nullbyte!
lea -SIZE(sp),sp
move.l sp,a5
; Libraries öffnen
lea IntName(pc),a1
moveq #34,d0
move.l $4.w,a6
jsr _LVOOpenLibrary(a6)
move.l d0,IntBase(a5)
bne.s .OpenDos
move.l #$38004,d7
bra ExitAlert
.OpenDos
lea DosName(pc),a1
moveq #34,d0
jsr _LVOOpenLibrary(a6)
move.l d0,DosBase(a5)
bne.s .AllocMem
move.l #$38007,d7
bra ExitAlert
; Speicher für Pref-Strukt reservieren
.AllocMem
move.l #pf_SIZEOF,d0
move.l #MEMF_PUBLIC+MEMF_CLEAR,d1
jsr _LVOAllocMem(a6)
move.l d0,prefBuff(a5)
bne.s OpenFilename
move.l #$10000,d7
bra ExitAlert
; Das File öffnen und einlesen
OpenFilename
lea FileName(pc),a0
move.l a0,d1
move.l #MODE_OLDFILE,d2
move.l DosBase(a5),a6
jsr _LVOOpen(a6)
move.l d0,FileH(a5)
bne.s LoadPref
move.l #$60007,d7
bra ExitAlert
LoadPref move.l d0,d1
move.l prefBuff(a5),d2
move.l #pf_SIZEOF,d3
jsr _LVORead(a6)
move.l prefBuff(a5),a0
move.l #pf_SIZEOF,d0
moveq #0,d1 ;FALSE, keine INFO
move.l IntBase(a5),a6
jsr _LVOSetPrefs(a6)
Ende moveq #0,d7 ;AlertFlag löschen
; Resourcen freigeben und auf ReturnFlag achten
ExitAlert move.l FileH(a5),d1
beq.s .freemem
move.l DosBase(a5),a6
jsr _LVOClose(a6)
.freemem move.l prefBuff(a5),d0
beq.s .closeDos
move.l d0,a1
move.l #pf_SIZEOF,d0
move.l $4.w,a6
jsr _LVOFreeMem(a6)
.closeDos move.l DosBase(a5),d0
beq.s .closeInt
move.l d0,a1
move.l $4.w,a6
jsr _LVOCloseLibrary(a6)
.closeInt move.l IntBase(a5),d0
beq.s .tstAlert
move.l d0,a1
move.l $4.w,a6
jsr _LVOCloseLibrary(a6)
; Alert aus Exec ausgeben, falls Fehler aufgetreten sind
.tstAlert tst.l d7
beq.s .weg
lea AlertParams(pc),a5
move.l $4.w,a6
jsr _LVOAlert(a6)
.weg lea SIZE(sp),sp ;Stack korrigieren!
Error_NULL moveq #0,d0
rts
AlertParams dc.l -1,-1
;*** Namen und Strings ***
IntName dc.b "intuition.library",0
even
DosName dc.b "dos.library",0
even
VersionsString dc.b "$VER: SetPrefs V1.0 (24.01.94)"
even
;*** Puffer ***
FileName ds.b 50